From e046db4b11ca8e684b87d42155b7478dcbc436bd Mon Sep 17 00:00:00 2001 From: Jeroen van der Heijden Date: Thu, 17 May 2018 16:19:54 +0200 Subject: [PATCH] Addd help and test fro stddev --- help/help_functions.md | 10 ++++++++++ test/test_select.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/help/help_functions.md b/help/help_functions.md index e89328ae..a14f2b73 100644 --- a/help/help_functions.md +++ b/help/help_functions.md @@ -159,6 +159,16 @@ Returns a float value. Returns the population variance of data, a non-empty iterable of real-valued numbers. Variance, or second moment about the mean, is a measure of the variability (spread or dispersion) of data. A large variance indicates that the data is spread out; a small variance indicates it is clustered closely around the mean. +stddev +------ +Syntax: + + stddev([ts]) + +Returns a float value. + +Returns the standard deviation which is the square root of its variance. + difference ---------- Syntax: diff --git a/test/test_select.py b/test/test_select.py index ace99b75..994c3afb 100644 --- a/test/test_select.py +++ b/test/test_select.py @@ -327,6 +327,20 @@ class TestSelect(TestBase): DATA['aggr'][-1][0], sum([x[1] for x in DATA['aggr']]) / len(DATA['aggr'])]]}) + self.assertAlmostEqual( + await self.client0.query('select stddev() from "aggr"'), + {'aggr': [[ + DATA['aggr'][-1][0], + 147.07108914792838]]}) + + self.assertAlmostEqual( + await self.client0.query('select stddev(1h) from "aggr"'), + {"aggr": [ + [1447250400, 1.8165902124584952], + [1447254000, 185.46409846162092], + [1447257600, 2.6457513110645907]]}) + + # test prefix, suffex result = await self.client0.query( 'select sum(1d) prefix "sum-" suffix "-sum", ' -- 2.30.2